package net.cjw.initsb.controller.test;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import net.cjw.initsb.cache.RedisCache;
import net.cjw.initsb.service.test.TestService;
import springfox.documentation.annotations.ApiIgnore;
@ApiIgnore
@RestController
public class RedisController {

	@Autowired
	private RedisCache redisCache;
	@Autowired
	private TestService testService;

	@GetMapping("redis")
	public String test2() {
		String key = "aaa";
		String hashKey = "aaa";
		redisCache.setHash(key, hashKey, "我是值");

		return redisCache.getHash(key, hashKey);

	}

	@GetMapping("redis_session")
	public String redisSession(HttpServletRequest request) {

		return "sessionid: " + request.getSession().getId();

	}

	@GetMapping("findTest")
	public String findTest() {
		return testService.find("aaa");
	}

	@GetMapping("updateTest")
	public String updateTest() {
		return testService.update("aaa");
	}

	@GetMapping("createTest")
	public String createTest() {
		return testService.create();
	}

}
